package intelligentCustomer.planning;

import java.util.ArrayList;
import java.util.List;

/**
 * 执行计划
 * 包含待执行的步骤序列
 */
public class Plan {
    private final List<PlanStep> steps = new ArrayList<>();
    private int currentStepIndex = 0;
    
    public void addStep(PlanStep step) {
        steps.add(step);
    }
    
    public void addSteps(List<PlanStep> newSteps) {
        steps.addAll(newSteps);
    }
    
    public PlanStep getNextStep() {
        if (currentStepIndex < steps.size()) {
            return steps.get(currentStepIndex++);
        }
        return null;
    }
    
    public PlanStep getCurrentStep() {
        if (currentStepIndex > 0 && currentStepIndex <= steps.size()) {
            return steps.get(currentStepIndex - 1);
        }
        return null;
    }
    
    public void retryCurrentStep() {
        if (currentStepIndex > 0) {
            currentStepIndex--;
        }
    }
    
    public List<PlanStep> getCompletedSteps() {
        return new ArrayList<>(steps.subList(0, currentStepIndex));
    }
    
    public boolean hasMoreSteps() {
        return currentStepIndex < steps.size();
    }
}